import 'package:flutter/material.dart';
import 'package:oramemo/generated/assets.dart';

class ProfileAvatar extends StatelessWidget {
  const ProfileAvatar({super.key, required this.onTap, required this.url});

  final String url;
  final Function() onTap;

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: onTap,
      child: Stack(
        alignment: Alignment.bottomRight,
        children: [
          Container(
            width: 120,
            height: 120,
            decoration: BoxDecoration(
              shape: BoxShape.circle,
              border: Border.all(
                color: Colors.white,
                width: 4,
              ),
              image: const DecorationImage(
                image: AssetImage(Assets.imagesHead),
                fit: BoxFit.cover,
              ),
            ),  child: url.isNotEmpty == true
              ? CircleAvatar(
            radius: 28,
            backgroundImage:
            NetworkImage(url),
          )
              : null,
          ),
          Container(
            padding: const EdgeInsets.all(8),
            decoration: const BoxDecoration(
              color: Colors.black45,
              shape: BoxShape.circle,
            ),
            child: const Icon(
              Icons.camera_alt,
              color: Colors.white,
              size: 20,
            ),
          ),
        ],
      ),
    );
  }
}
